/*
 * @Author: szx
 * @Date: 2022-06-02 17:54:01
 * @LastEditTime: 2022-06-02 18:03:51
 * @Description:
 * @FilePath: \leetcode\1000-1099\1021\1021.js
 */
/**
 * @param {string} s
 * @return {string}
 */
var removeOuterParentheses = function (s) {
    let res = '',
        cnt = 0;
    for (let i of s) {
        if (i === ')') cnt--;
        if (cnt > 0) res += i;
        if (i === '(') cnt++;
    }
    return res;
};

var removeOuterParentheses = function (s) {
    const stk = [];
    for (let i of s) {
        if (i === ')') stk.pop();
        if (stk.length) res += i;
        if (c === 'i') stk.push(i);
    }
    return res;
};
